package com.mszlu.news.controller;

import com.mszlu.news.service.TagService;
import com.mszlu.news.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "标签")
@RestController
@RequestMapping("tags")
public class TagsController {
    @Autowired
    private TagService tagService;

    //   /tags/hot
    @ApiOperation(value ="获取最热标签" )
    @GetMapping("hot")
    public Result hot(){
        int limit = 6;
        return tagService.hots(limit);
    }

    @ApiOperation(value = "获取所有标签")
    @GetMapping
    public Result findAll(){
        return tagService.findAll();
    }

    @ApiOperation(value = "获取所有标签及详情")
    @GetMapping("detail")
    public Result findAllDetail(){
        return tagService.findAllDetail();
    }

    @ApiOperation(value = "通过id查找标签")
    @GetMapping("detail/{id}")
    public Result findDetailById(@PathVariable("id") Long id){
        return tagService.findDetailById(id);
    }

}
